<?PHP
include_once "ini.php";
$id_user = $_GET['id'];
dbconnect();
$json = array ();
$i=0;

$query = "SELECT * FROM tags WHERE id_user = '".$id_user."';";
$result = mysql_query($query);
if (!$result)
{
    echo "SQL error : ", $query;
    exit ;
}
else
{
    while ($tab = mysql_fetch_assoc($result))
    {
        $sql = "SELECT * FROM indexation WHERE id_mot = '".$tab['id_mot']."';";
        $requete = mysql_query($sql);
        if (!$requete)
        {
            echo "SQL error : ", $sql;
            exit ;
        }
        else
        {
        	while($tableau = mysql_fetch_assoc($requete)){
        		$json[$i] = array("id_mot" => $tableau['id_mot'],"keyword" => $tableau['keyword'],"tag_occurence" => $tab['tag_occurence']);
				$i++;
        	}
        }
    }
}
echo json_encode($json);
dbclose();
?>
